<template>
  <view>
    <view class="publishContain defaultMain">
      <u-cell-group>
        <u-cell-item
          title="标题"
          :arrow="false"
          :border="false"
          required
          :value="title"
        ></u-cell-item>
        <u-cell-item
          title="事件类别"
          :arrow="false"
          :border="false"
          required
          :value="category_name"
        ></u-cell-item>
      </u-cell-group>
      <mypicture ref="mypicture" type="detail" :album-list="takePicList">
        <view>拍照</view>
      </mypicture>
      <myvideo ref="myvideo" type="detail" :old-video-list="videoList">
        <view>录像</view>
      </myvideo>
      <!-- 描述 -->
      <view class="desStyle">
        <view class="desLabel">
          <view style="margin-bottom: 26rpx;">描述</view>
          <image
            @click="showMap"
            style="width: 50rpx;height: 50rpx;"
            src="/static/img/icons/mark_blue.png"
            mode="scaleToFill"
          />
        </view>
        <view class="desContent">
          {{ description }}
        </view>
      </view>
      <view class="desStyle">
        <view class="desLabel">
          <view style="margin-bottom: 26rpx;">驳回原因</view>
        </view>
        <u-input
          v-model="fail_reason"
          :type="type"
          :border="border"
          width="750"
          height="150"
          :auto-height="autoHeight"
          placeholder="请输入驳回原因"
        />
      </view>
      <!-- 驳回按钮 -->
      <view class="suishoupaiButton">
        <u-button
          type="primary"
          :ripple="true"
          ripple-bg-color="#74b9ff"
          @click="submitSuiShouPai"
          >驳回</u-button
        >
      </view>
    </view>
    <mapselect
      ref="mapSelect"
      v-show="mapVisible"
      @saveMap="saveMap"
    ></mapselect>
  </view>
</template>
<script>
import mypicture from "../picvideo/picture.vue";
import myvideo from "../picvideo/video.vue";
import mapselect from "../map/map.vue";
import { contentInfo } from "../../../common/api/suishoupai";
import { myAuditSubmit } from "../../../common/api/mine";
let that;
export default {
  name: "allNeedFeed",
  components: {
    mapselect,
    mypicture,
    myvideo,
  },
  onLoad(options) {
    that = this;
    // console.log(this.$Router.extract(options));
    const { content_id, feedBadgeNum, auditBadgeNum, finishedBadgeNum }= this.$Router.extract(options)
    this.feedBadgeNum = feedBadgeNum
    this.auditBadgeNum = auditBadgeNum
    this.finishedBadgeNum = finishedBadgeNum
    contentInfo({ content_id: content_id }).then((res) => {
      // console.log("suiDetail mounted---", typeof res.imgs, res);
      this.content_id = res.content_id;
      this.title = res.name;
      this.category_id = res.category_id;
      this.category_name = res.category_name;
      this.description = res.description;
      this.takePicList = res.imgs;
      this.$refs.mypicture.$data.takePicList = res.imgs;
      this.videoList = res.videos;
      this.$refs.myvideo.$data.videoList = res.videos;
      this.photographFree.latitude = res.latitude;
      this.photographFree.longitude = res.longitude;
    });
    uni.pageScrollTo({//uni-app中页面滚动接口
      scrollTop: 1000,//滚动到页面的目标位置（单位px）
    })

  },
  data() {
    return {
      // record: {},
      // 数量
      feedBadgeNum: 0,
      auditBadgeNum: 0,
      finishedBadgeNum: 0,
      title: '',
      category_name: '',
      description: '',
      fail_reason: '',
      takePicList: [],
      videoList: [],
      // 地图
      mapVisible: false,
      photographFree: {
        latitude: null,
        longitude: null,
      },
      // 描述
      type: "textarea",
      border: true,
      width: 750,
      height: 150,
      autoHeight: true,
    };
  },
  methods: {
    showMap() {
      this.mapVisible = true;
      this.$refs.mapSelect.reAuth(
        this.photographFree.longitude,
        this.photographFree.latitude
      );
    },
    // 坐标保存
    async saveMap(point) {
      this.mapVisible = false;
    },
    submitSuiShouPai() {
      if (!this.fail_reason) {
        uni.showToast({
          title: "请填写驳回原因",
          icon: "error",
          mask: true
        })
        return
      }
      uni.showLoading({
        title: "提交中",
        mask: true,
      });
      // console.log("驳回");
      const Data = {
        content_id: that.content_id,
        audit_status: 4,
        fail_reason: that.fail_reason,
      };
      myAuditSubmit(Data).then(() => {
        // that.$parent.feedBadgeNum = that.feedBadgeNum - 1
        uni.hideLoading()
        uni.showToast({
          title: '已驳回成功!',
          icon: "success",
          mask: true
        });
        setTimeout(()=>{
            uni.navigateBack({
              delta: 1
            });
            /* that.$Router.push({
              name: 'myAudit',
              data: {
                allNeedFeed: this.feedBadgeNum - 1,
                allNeedAudit: this.auditBadgeNum,
                allFinished: this.finishedBadgeNum + 1
              }
            }) */
          },1000)
      });
    }
  },
};
</script>
<style lang="scss" scoped>
.publishContain {
  padding: 0 0 170rpx;
  background-color: #fff;
}
.desStyle {
  padding: 20rpx;
  background-color: #fff;
  border-bottom: 1px solid #eee;
}
.desLabel {
  display: flex;
  justify-content: space-between;
}
.desContent {
  width: 100%;
  min-height: 200rpx;
  padding: 20rpx;
  border: 1rpx solid #eee;
  border-radius: 10rpx;
}
.suishoupaiButton {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 148rpx;
  box-sizing: border-box;
  padding: 0 30rpx;
  position: fixed;
  background-color: #ffffff;
  bottom: 0;
  text-align: center;
  box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.1);
  z-index: 999;
}
.suishoupaiButton u-button {
  width: 100%;
  border-radius: 10rpx;
}
</style>
